package com.backend.mapper;

import com.backend.entity.entity.Users;
import com.backend.entity.entity.WorkOrders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RepairmanMapper {
    //根据状态获取工单
    @Select("SELECT * FROM work_orders WHERE status = #{status} ")
    List<WorkOrders> getWorkOrderByStatus(Integer status);
    //更新工单状态
    @Update("UPDATE work_orders SET status = #{status} WHERE order_id = #{orderId}")
    void updateWorkOrderStatus(@Param("orderId")  Integer orderId,@Param("status") Integer status);
    //获取工单详情
    @Select("SELECT * FROM work_orders WHERE order_id = #{orderId}")
    WorkOrders getWorkOrderDetail(Integer orderId);
    //查询所有维修工信息
    @Select("SELECT * FROM users WHERE role=1")
    List<Users> getAllRepairman();
    //根据状态获取工单
    @Select("SELECT * FROM work_orders WHERE status = #{status} AND repairman_id=#{repairId}")
    List<WorkOrders> getWorkOrderByStatusAndRepairId(@Param("status")Integer status,@Param("repairId") Integer repairId);
}
